package com.zephyr.vchcenter.bpm.action;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;

import com.hiaward.bpm.action.TaskAction;
import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.ServiceException;
import com.hiaward.framework.taskmanage.service.Service;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.bpm.util.RandomUtil;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class IdentifyExpAction extends TaskAction {
	private final Logger log = Logger.getLogger(IdentifyExpAction.class);

	@Override
	public void perform(ServiceContext context) throws ServiceException,
			ParameterException {
		log.debug("����IdentifyExpAction进入IdentifyExpAction...........");
		String vchsid=(String)context.getInputParameterValue("vchsid");
	    String idstate=(String)context.getInputParameterValue("idstate");
	    IBaseDao dao=(IBaseDao)SpringHelper.getBean("baseDao");
        Voucher voucher=(Voucher)dao.findById("Voucher", vchsid);
        log.debug("���˽��--------="+idstate);
        if("4".equals(idstate)){
        	log.debug("����ͨ���������");
        	voucher.setIdstate("4");
        	
        }else{
        	log.debug("���˲�ͨ���������");
        	voucher.setIdstate("6");
        	voucher.setIdresult("4");
        }
        dao.saveOrUpdate(voucher);
	    /*  RandomUtil randomUtil=new RandomUtil();
		String accno=(String)context.getInputParameterValue("accnoInput");
		String amount=(String)context.getInputParameterValue("amountInput");
		String vchno=(String)context.getInputParameterValue("vchnoInput");
		String subno=(String)context.getInputParameterValue("subnoInput");
		String brbank=(String)context.getInputParameterValue("brbankInput");
		String vsbank=(String)context.getInputParameterValue("vsbankInput");
		String vchsid=(String)context.getInputParameterValue("vchsid");
		ApplicationContext applicationContext=randomUtil.getApplicationContext();
		Service service=(Service)applicationContext.getBean("daoService");
		Voucher voucher=(Voucher)service.getObject(Voucher.class, vchsid);
		voucher.setAccno(accno);
		voucher.setAmount(amount);
		voucher.setVchno(vchno);
		voucher.setSubno(subno);
		voucher.setBrbank(brbank);
		voucher.setVsbank(vsbank);*/
		log.debug("离开IdentifyExpAction...............");
	}

	@Override
	public void serviceExceptionHandle(ServiceContext arg0,
			ServiceException arg1) {

	}

}
